package com.yycx.module.bus.provider.controller.hy;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.module.bus.provider.service.BusDrugsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yycx.common.mybatis.model.*;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;
import com.yycx.common.springmvc.base.BaseController;
import com.yycx.module.bus.client.entity.hy.BusPolicyDrug;
import com.yycx.module.bus.provider.service.hy.BusPolicyDrugService;


/**
 * 商品全局政策控制器
 *
 * @author flyme
 * @date 2023-07-16
 */
@RestController
@RequestMapping("/bus/bpd/")
public class BusPolicyDrugController extends BaseController<BusPolicyDrugService, BusPolicyDrug> {

    @Autowired
    private BusDrugsService drugsService;

    @ApiOperation(value = "商品全局政策-分页列表", notes = "商品全局政策分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        return bizService.pageList(params);
    }

    @ApiOperation(value = "商品全局政策-列表", notes = "商品全局政策列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Map params) {
        return bizService.listEntityMap(params);
    }

    @ApiOperation(value = "商品全局政策-添加", notes = "添加商品全局政策")
    @PostMapping(value = "save")
    public ResultBody save(@RequestParam(required = false) Map params) {
        return bizService.add(params);
    }

    @ApiOperation(value = "商品全局政策-更新", notes = "更新商品全局政策")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "商品全局政策-删除", notes = "删除商品全局政策")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "商品全局政策-详情", notes = "商品全局政策详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }


    @ApiOperation(value = "根据商品ID查询商品批号", notes = "根据商品ID查询商品批号")
    @GetMapping(value = "selectLotNoByDrugsId")
    public ResultBody selectLotNoByDrugsId(String drugNo, String hyDeptNo) {
        List<EntityMap> list = drugsService.selectLotNoByDrugsId(drugNo, hyDeptNo);
        return ResultBody.ok(list);
    }

    @ApiOperation(value = "查询客户商品销售历史", notes = "查询客户商品销售历史")
    @GetMapping(value = "getHistoryDrug")
    public ResultBody getHistoryDrug(String drugNo, String customCode) {
        List<EntityMap> list = drugsService.getHistoryDrug(customCode, drugNo);
        return ResultBody.ok(list);
    }

    @ApiOperation(value = "查询海鹰商品", notes = "查询海鹰商品")
    @GetMapping(value = "selectTop10HyDrugList")
    public ResultBody selectTop10HyDrugList(String hyDeptNo, String title) {
        List<EntityMap> list = drugsService.selectTop10HyDrugList(hyDeptNo, title);
        return ResultBody.ok(list);
    }


    @ApiOperation(value = "重新计算在单数", notes = "重新计算在单数")
    @PostMapping(value = "updateOnUseCount")
    public ResultBody updateOnUseCount(Integer drugLotId, String drugNo, String drugLotNo, String storeCode) {
        return drugsService.updateOnUseCount(drugLotId, drugNo, drugLotNo, storeCode);
    }


    @ApiOperation(value = "重新商品目录计算在单数", notes = "重新商品目录计算在单数")
    @PostMapping(value = "updateDrugOnUseCount")
    public ResultBody updateDrugOnUseCount(String drugNo) {
        return drugsService.updateDrugOnUseCount( drugNo);
    }
}
